Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix memory leak of grpc resolver #4490

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sauryniu
Copy link

Fix memory leak issue
There are two situations:

  1. The same grpc client is created repeatedly.
  2. Resolver.Close is called when grpc enters idle mode, and the resolver will be re-created the next time rpc is called.

c, exists := r.getCluster(endpoints)
// if not exists, return.
if !exists {
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not exist, getCluster will create a cluster and save it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I have considered this issue originally. I have written a new method to obtain the cluster, but usually the cluster has already been created when the Monitor is called first, so I deleted this method. To take a step back, generally speaking, when we use etcd, the endpoints are often the same, so even if a new cluster is created, it will have little impact.

@kevwan
Copy link
Contributor

kevwan commented Jan 1, 2025

Will be merged in v1.8.0. This PR uses slices package from go1.21, and we'll upgrade to this go version in v1.8.0.

Copy link

codecov bot commented Jan 4, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 8 lines in your changes missing coverage. Please review.

Project coverage is 94.52%. Comparing base (8690859) to head (30747e9).
Report is 204 commits behind head on master.

Files with missing lines Patch % Lines
core/discov/subscriber.go 73.33% 3 Missing and 1 partial ⚠️
core/discov/internal/registry.go 76.92% 2 Missing and 1 partial ⚠️
zrpc/resolver/internal/discovbuilder.go 0.00% 1 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
zrpc/resolver/internal/resolver.go 100.00% <100.00%> (ø)
zrpc/resolver/internal/discovbuilder.go 37.03% <0.00%> (-1.43%) ⬇️
core/discov/internal/registry.go 79.44% <76.92%> (+0.53%) ⬆️
core/discov/subscriber.go 78.33% <73.33%> (-6.49%) ⬇️

... and 7 files with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants